import re

def update_jd_sku(smzdm):
    m = re.search(r'\|2F(\d{6,12})\|', smzdm.remark)
    if not smzdm.active and m:
        smzdm.commodity_sku = m.group(1)
        smzdm.mall_url = 'https://item.jd.com/%s.html' %m.group(1)
        if smzdm.mall_url: smzdm.active = True
    m = re.search(r'\|(\d{7})\|', smzdm.remark)
    if not smzdm.active and m:
        smzdm.commodity_sku = m.group(1)
        smzdm.mall_url = 'https://item.jd.com/%s.html' %m.group(1)
        if smzdm.mall_url: smzdm.active = True
    m = re.search(r'\|(\d{11})\|', smzdm.remark)
    if not smzdm.active and m:
        smzdm.commodity_sku = m.group(1)
        smzdm.mall_url = 'https://item.jd.com/%s.html' %m.group(1)
        if smzdm.mall_url: smzdm.active = True
    m = re.search(r'\|(\d{6})\|', smzdm.remark)
    if not smzdm.active and m:
        smzdm.commodity_sku = m.group(1)
        smzdm.mall_url = 'https://item.jd.com/%s.html' %m.group(1)
        if smzdm.mall_url: smzdm.active = True
    return smzdm

def update_jd_hk_sku(smzdm):
    m = re.search(r'\|2F(\d{6,12})\|', smzdm.remark)
    if not smzdm.active and m:
        smzdm.commodity_sku = m.group(1)
        smzdm.mall_url = 'https://item.jd.hk/%s.html' %m.group(1)
        if smzdm.mall_url: smzdm.active = True
    m = re.search(r'\|(\d{7})\|', smzdm.remark)
    if not smzdm.active and m:
        smzdm.commodity_sku = m.group(1)
        smzdm.mall_url = 'https://item.jd.hk/%s.html' %m.group(1)
        if smzdm.mall_url: smzdm.active = True
    m = re.search(r'\|(\d{11})\|', smzdm.remark)
    if not smzdm.active and m:
        smzdm.commodity_sku = m.group(1)
        smzdm.mall_url = 'https://item.jd.hk/%s.html' %m.group(1)
        if smzdm.mall_url: smzdm.active = True
    return smzdm
